<?php

namespace lico\Runtime;

use lico\Runtime\Route;
use lico\Runtime\Response;

use lico\Container;

class App
{
    protected $_route;
    protected $_response;
    public function __construct(Route $route,Response $response)
    {
        $this->_route = $route;
        $this->_response = $response;
    
        // Container::getBowl('lico\MVC\Controller');
        // Container::getBowl('lico\MVC\Model');
        // Container::getBowl('lico\MVC\View');
    }

    public function run()
    {
        $controller = $this->_route->controllerNameSpace();
        $method = $this->_route->method();
        // $response = call_user_func([new $controller,$method]);
        // p($controller);
        $response = Container::getBowl($controller)->$method();
        
        if ($response) {
            $this->_response->setData($response);
            // p($this->_response->getData());
        }
        return true;
    }
}
